/*
 * Copyright (c) 2006-2020, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2020-12-06     acer       the first version
 */
#include "led.h"
#include <agile_led.h>
#include <drv_gpio.h>
#include <stdlib.h>

#define LED_RUN_PIN    GET_PIN(C, 1)
#define LED_DATA_PIN    GET_PIN(C, 2)

agile_led_t *led_run = RT_NULL;
agile_led_t *led_data = RT_NULL;

void led_init(void)
{
    if(led_run == RT_NULL)
    {
        led_run = agile_led_create(LED_RUN_PIN, PIN_LOW, "500,200,200", -1);
    }

    if(led_data == RT_NULL)
    {
        led_data = agile_led_create(LED_DATA_PIN, PIN_LOW, "200,100", -1);
    }

    agile_led_start(led_run);
}

void led_run_set_mode(enum led_run_mode mode)
{
    static enum led_run_mode now_mode = LED_RUN_MODE_LINK_DOWN;
    if(mode != now_mode)
    {
        switch (mode)
        {
            case LED_RUN_MODE_LINK_DOWN:
                agile_led_set_light_mode(led_run, "500,200,200", -1);
                break;
            case LED_RUN_MODE_LINK_UP:
                agile_led_set_light_mode(led_run, "500,500", -1);
                break;
            default:
                break;
        }
        now_mode = mode;
    }
}

